package com.shenfa.action;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.shenfa.action.upload.DownloadAction;
import com.shenfa.bean.BillStencil;
import com.shenfa.bean.BillStencilArea;
import com.shenfa.bean.BillStencilSub;
import com.shenfa.service.BillStencilService;

import com.shenfa.util.ResultObject;

/**
 * 账单管理-模板管理 Action
 * 
 * @author 张瑶
 * @date 2011-08-24
 */
public class BillStencilAction extends BaseAction {

	private static final long serialVersionUID = -368217842923763771L;
	@Autowired
	private BillStencilService billStencilService;
	
	private static Logger log=Logger.getLogger(DownloadAction.class);
	private BillStencil billStencil;
	private BillStencilSub billStencilSub;
	private BillStencilArea billStencilArea;

	/**
	 * 模糊查询模块主表信息
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String selectBillStencil() {
		log.debug("billStencil="+billStencil);
		int skip = 0;
		int max = 10;
		List<BillStencil> list = billStencilService.selectBillStencil(billStencil, skip, max);
		result = ResultObject.build("0", list);
		result.put("total", 10);

		return SUCCESS;
	}

	/**
	 * 增加模板主表信息
	 * 
	 * @return
	 */
	public String insertBillStencil() {
		log.debug("billStencil="+billStencil);
		Object object = billStencilService.insertBillStencil(billStencil);
		if (null == object) {
			return ERROR;
		} else {
			return SUCCESS;
		}
	}

	/**
	 * 更新模板主表信息
	 * 
	 * @return
	 */
	public String updateBillStencil() {
		log.debug(billStencil.toString());
		int rows = billStencilService.updateBillStencil(billStencil);
		if (rows > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	/**
	 * 刪除模板主表信息
	 * 
	 * @return
	 */
	public String deleteBillStencil() {
		log.debug("stencilNo="+billStencil.getStencilno());
		int rows = billStencilService.deleteBillStencil(billStencil);
		if (rows > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	/**
	 * 模糊查询模板从表信息
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String selsctBillStencilSub() {
		log.debug("inName="+billStencilSub.getInname()+",inNo="+billStencilSub.getInno()+",stencilNo="+billStencilSub.getStencilno()+",version="+billStencilSub.getVersion());
		int skip = 0;
		int max = 10;
		List<BillStencilSub> list = billStencilService.selsctBillStencilSub(billStencilSub, skip, max);
		result = ResultObject.build("0", list);
		result.put("total", 10);
		return SUCCESS;
	}

	/**
	 * 增加模板从表信息
	 * 
	 * @return
	 */
	public String insertBillStencilSub() {
		log.debug("inName="+billStencilSub.getInname()+",inNo="+billStencilSub.getInno()+",stencilNo="+billStencilSub.getStencilno()+",version="+billStencilSub.getVersion());
		Object object = billStencilService.insertBillStencilSub(billStencilSub);
		if (null == object) {
			return ERROR;
		} else {
			return SUCCESS;
		}
	}

	/**
	 * 更新模板从表信息
	 * 
	 * @return
	 */
	public String updateBillStencilSub() {
		log.debug("inName="+billStencilSub.getInname()+",inNo="+billStencilSub.getInno()+",stencilNo="+billStencilSub.getStencilno()+",version="+billStencilSub.getVersion());
		int rows = billStencilService.updateBillStencilSub(billStencilSub);
		if (rows > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	/**
	 * 刪除模板从表信息
	 * 
	 * @return
	 */
	public String deleteBillStencilSub() {
		log.debug("inNo="+billStencilSub.getInno()+",stencilNo="+billStencilSub.getStencilno()+",version="+billStencilSub.getVersion());
		int rows = billStencilService.deleteBillStencilSub(billStencilSub);
		if (rows > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	/**
	 * 模糊查询模板个性化区域表信息
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String selsctBillStencilArea() {
		log.debug("areaName="+billStencilArea.getAreaname()+",areaNo="+billStencilArea.getAreano()+",remark="+billStencilArea.getRemark()+",stencilNo="+billStencilArea.getStencilno()
				+",typeNo="+billStencilArea.getTypeno()+",version="+billStencilArea.getVersion());
		int skip = 0;
		int max = 10;
		List<BillStencilArea> list = billStencilService.selsctBillStencilArea(billStencilArea, skip, max);
		result = ResultObject.build("0", list);
		result.put("total", 10);
		return SUCCESS;
	}

	/**
	 * 增加模板个性化区域表信息
	 * 
	 * @return
	 */
	public String insertBillStencilArea() {
		log.debug("areaName="+billStencilArea.getAreaname()+",areaNo="+billStencilArea.getAreano()+",remark="+billStencilArea.getRemark()+",stencilNo="+billStencilArea.getStencilno()
				+",typeNo="+billStencilArea.getTypeno()+",version="+billStencilArea.getVersion());
		Object object = billStencilService.insertBillStencilArea(billStencilArea);
		if (null == object) {
			return ERROR;
		} else {
			return SUCCESS;
		}
	}

	/**
	 * 更新模板个性化区域表信息
	 * 
	 * @return
	 */
	public String updateBillStencilArea() {
		log.debug("areaName="+billStencilArea.getAreaname()+",areaNo="+billStencilArea.getAreano()+",remark="+billStencilArea.getRemark()+",stencilNo="+billStencilArea.getStencilno()
				+",typeNo="+billStencilArea.getTypeno()+",version="+billStencilArea.getVersion());
		int rows = billStencilService.updateBillStencilArea(billStencilArea);
		if (rows > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	/**
	 * 刪除模板个性化区域表信息
	 * 
	 * @return
	 */
	public String deleteBillStencilArea() {
		log.debug("areaNo="+billStencilArea.getAreano()+",stencilNo="+billStencilArea.getStencilno()+",version="+billStencilArea.getVersion());
		int rows = billStencilService.deleteBillStencilArea(billStencilArea);
		if (rows > 0) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	public void setBillStencil(BillStencil billStencil) {
		this.billStencil = billStencil;
	}

	public BillStencil getBillStencil() {
		return billStencil;
	}

	public BillStencilSub getBillStencilSub() {
		return billStencilSub;
	}

	public void setBillStencilSub(BillStencilSub billStencilSub) {
		this.billStencilSub = billStencilSub;
	}

	public BillStencilArea getBillStencilArea() {
		return billStencilArea;
	}

	public void setBillStencilArea(BillStencilArea billStencilArea) {
		this.billStencilArea = billStencilArea;
	}

}
